BIN     = nrfcam
OBJ     = main.o lzf_c.o tcm8230md.o nrf24l01p.o eint_hdlr.o
LIB     = -lc -lm -llpc1768
AFLAGS  = -mcpu=cortex-m3 -mthumb 
CFLAGS  = -mcpu=cortex-m3 -mthumb -msoft-float -falign-functions=64 -O2 -ggdb -Wall -I. -I./include/ -I/usr/local/lpc1768/include
LDFLAGS = -mcpu=cortex-m3 -mthumb -msoft-float -Wl,-Map=$(BIN).map -T/usr/local/lpc1768/lpc1768.ld -L. -L./lib/ -L/usr/local/lpc1768/lib

CC = arm-none-eabi-gcc
AS = arm-none-eabi-as
LD = arm-none-eabi-ld
AR = arm-none-eabi-ar
RM = rm -f 
SIZE    = arm-none-eabi-size
STRIP   = arm-none-eabi-strip -s
OBJCOPY = arm-none-eabi-objcopy
OBJDUMP = arm-none-eabi-objdump
CHECKSUM= cm3_checksum

all:: $(BIN)

$(BIN): $(OBJ)
	$(CC) $(LDFLAGS) $(OBJ) $(LIB) -o $(BIN).elf
	$(OBJCOPY) -Oihex -j .text -j .data $(BIN).elf $(BIN).hex
	$(OBJCOPY) -Obinary  -j .text -j .data $(BIN).elf $(BIN).bin
	$(CHECKSUM) $(BIN).bin

clean:
stats: $(BIN).elf
	$(SIZE) $(BIN).elf

clean:
	$(RM) *.o *.elf *.bin *.map *.hex

install:
	cp $(BIN).bin /media/MBED/ && sync

.c.o :
	$(CC) $(CFLAGS) -c $<

.s.o :
	$(AS) $(AFLAGS) $< -o $@
